MOD = 10 ** 9 + 7

def power(x, n):
	res = 1
	for _ in range(n):
		res = res * x % MOD
	return res

def power2(x, n):
	res = 1
	pow = x
	while n:
		if n & 1:
			res = res * pow % MOD
		pow = pow * pow % MOD
		n >>= 1
	return res



print(power(3, 3))
print(power(3, 0))
print(power2(3, 3))
print(power2(3, 0))